
#[=======================================================================[.rst:

 For more information about using CMake with Android Studio, read the
 documentation: https://d.android.com/studio/projects/add-native-code.html

 Sets the minimum version of CMake required to build the native library.


#]=======================================================================]
cmake_minimum_required(VERSION 3.10.2)
project("all-dev")
# set cmake default folder name
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
SET_PROPERTY(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "cmake")
# Append our module directory to CMake
LIST( APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules )


FIND_PACKAGE(Yate REQUIRED )
MESSAGE( STATUS "Yate_LIBRARIES: " ${Yate_LIBRARIES} )
MESSAGE( STATUS "Yate_INCLUDE_DIRS: " ${Yate_INCLUDE_DIR} )
SET( yate_engine_lib ${Yate_LIBRARIES} )

IF(WIN32)
	add_compile_options(/W4)
    add_compile_options(/wd4996 /wd4100)
ENDIF()

if(VCPKG_TARGET_TRIPLET)
	ADD_DEFINITIONS(-D_WITH_VCPKG_BUILD_=${VCPKG_TARGET_TRIPLET})
endif()

## 头文件目录
INCLUDE_DIRECTORIES( 
	${Yate_INCLUDE_DIR}
)

##===========================================================
## libs

ADD_SUBDIRECTORY(libs)

if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules)
	ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/modules)
endif()

##===========================================================
## modules-group

if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules-group-ai)
	ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/modules-group-ai)
endif()

if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules-group-dev)
	ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/modules-group-dev)
endif()

if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules-group-demo)
	ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/modules-group-demo)
endif()

if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules-group-fbus)
	ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/modules-group-fbus)
endif()

if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules-group-qt)
	ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/modules-group-qt)
endif()

if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules-group-skf)
	ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/modules-group-skf)
endif()

if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules-group-grpc)
	ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/modules-group-grpc)
endif()

if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules-group-ohos)
	ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/modules-group-ohos)
endif()


## =========================================================================

ADD_EXECUTABLE(yate
	main.cpp
)
SET_PROPERTY(TARGET yate PROPERTY FOLDER "apps")
# 链接Yate库
TARGET_LINK_LIBRARIES( yate ${yate_engine_lib} )

SET_TARGET_PROPERTIES( yate PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX} )

# 安装二进制文件，Binaries
INSTALL (TARGETS yate DESTINATION .)

if( EXISTS apps )
	ADD_SUBDIRECTORY(apps)
endif()

## =========================================================================

if(WIN32)

## 安装conf.d目录下文件
INSTALL(FILES conf.d.win32/yate.conf 
		DESTINATION conf.d 
		)

else()
	
## 安装conf.d目录下文件
INSTALL(DIRECTORY conf.d 
		DESTINATION .
		)
	
endif()	

## =========================================================================

if( EXISTS ${YATE_PREFIX_PATH}/yate/lib/libyateengine.so )
	INSTALL( FILES ${YATE_PREFIX_PATH}/yate/lib/libyateengine.so
			DESTINATION .
			PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
				  GROUP_EXECUTE GROUP_READ
		)
endif()

if( EXISTS ${YATE_PREFIX_PATH}/yate/lib/yateengine.dll )
	INSTALL( FILES ${YATE_PREFIX_PATH}/yate/lib/yateengine.dll
			DESTINATION .
			PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
				  GROUP_EXECUTE GROUP_READ
		)

endif()



if(NOT WIN32)

	# 安装运行脚本	
	INSTALL( PROGRAMS run.console
		DESTINATION .
		PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
			  GROUP_EXECUTE GROUP_READ	
		)
		
	# 安装运行脚本	
	INSTALL( PROGRAMS run.daemon
		DESTINATION .
	   PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
			  GROUP_EXECUTE GROUP_READ
		)


endif()

	
	


